<template>
	<view class="qarecord">
		<image class="qarecord_bk_img" :src="onlinePic+'answer/qarecord_bk.png'" mode="widthFix"></image>
		<view class="qarecord_box">
			<view class="text-c f-18 c-white mt-30">{{recordinfo.title}}</view>
			<view class="f-13 c-white mt-25 ml-10">温馨提示：</view>
			<view class="f-13 c-white ml-10">
				<text>{{recordinfo.desc}}</text>
			</view>
			<view class="qarecord_cell_box">
				<view v-for="item in list" class="qarecord_cell c-666666 ellipsis-2" @click="goInfo(item.button_url)">
					{{item.content}}
					<span class="check_info ml-5">{{item.button}}</span>
				</view>
			</view>
		</view>
		<view class="bk_bottom"></view>
	</view>
</template>

<script>
	import {
		getQaInfo,
		getSeasonRecord
	} from '@/api/motortime.js';
	let app = getApp()
	export default {
		data() {
			return {
				info: '',
				list: [],
				recordinfo: '',
				subject_id: '',
				picUrl: app.globalData.picUrl,
				onlinePic: app.globalData.onlinePic,
			};
		},
		onShow() {

		},
		onLoad(options) {
			this.subject_id = options.subject_id
			this.channel = options.channel ? options.channel : ''
			this.getQaInfo()
			this.getSeasonRecord()
		},
		methods: {
			getQaInfo() {
				getQaInfo({
					channel: this.channel,
					subject_id: this.subject_id,
				}).then(res => {
					if (res.state == 1) {
						this.info = res.data
						uni.setNavigationBarTitle({
							title: res.data.top
						})
						this.showStart = true
						var params = {
							event_code: '参赛记录',
							event_id: this.subject_id,
							title: res.data.title,
							value: '',
							path: 'pages/qa/qarecord/qarecord',
						}
						app.BurialPoint(params)
					} else {
						uni.showToast({
							title: res.error[0],
							mask: true,
							icon: 'none',
							duration: 1500
						})
					}
				})
			},
			getSeasonRecord() {
				getSeasonRecord({
					channel: this.channel,
					subject_id: this.subject_id,
				}).then(res => {
					if (res.state == 1) {
						this.list = res.data.info.list
						this.recordinfo = res.data.info.info
					} else {
						uni.showToast({
							title: res.error[0],
							mask: true,
							icon: 'none',
							duration: 1500
						})
					}
				})
			},
			goInfo(url) {
				if (url) {
					uni.navigateTo({
						url: url
					})
					var params = {
						event_code: '参赛记录',
						event_id: this.subject_id,
						title: this.recordinfo.title,
						value: '',
						path: 'pages/qa/qarecord/qarecord',
						source_page: '参赛记录-点击详情',
					}
					app.BurialPoint(params)
				}
			}
		},
		onShareAppMessage(res) {
			app.getShareTask()
			return {
				title: this.info.title ? this.info.title : '答题',
				imageUrl: this.info.share_img ? this.info.share_img : '',
				path: '/pages/qa/qastart/qastart?subject_id=' + this.subject_id + '&channel=' + this.channel
			}
		},
	}
</script>

<style lang="scss">
	page {
		background-color: #f1f1f1;
	}

	.qarecord {
		height: 100vh;
		position: relative;
		overflow: hidden;

		.qarecord_bk_img {
			width: 100%;
			vertical-align: middle;
		}

		.qarecord_box {
			position: absolute;
			top: 0;
			right: 0;
			bottom: 0;
			left: 0;
			z-index: 2;
			padding: 0 30rpx;

			.qarecord_cell_box {
				height: calc(100vh - 350rpx);
				margin-top: 40rpx;
				padding: 0 40rpx;
				border-radius: 8rpx;
				overflow-y: auto;
				background-color: #ffffff;

				.qarecord_cell {
					font-size: 26rpx;
					padding: 40rpx 20rpx;
					line-height: 36rpx;
					border-bottom: 1rpx solid rgba(0, 0, 0, .12);
				}

				.qarecord_cell:last-child {
					border-bottom: none;
				}

				.check_info {
					color: #00A0DC;
					text-decoration: underline;
				}
			}
		}

		.bk_bottom {
			height: 230rpx;
			position: absolute;
			bottom: 0;
			left: 0;
			right: 0;
			z-index: 1;
			background-image: linear-gradient(to top, rgba(0, 160, 220, 0.2), #f1f1f1);
		}
	}
</style>